package com.ruitu.ssmic.ui;

import android.os.Bundle;

import com.ruitu.arad.Arad;
import com.ruitu.arad.base.BaseActivity;
import com.ruitu.arad.support.view.NoScrollViewPager;
import com.ruitu.router_module.bean.EventModel;
import com.ruitu.ssmic.R;
import com.ruitu.ssmic.ui.fragment.PhoneFragemnt;
import com.ruitu.ssmic.ui.fragment.VersionPasswordFragment;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class ForgetPasswordActivity extends BaseActivity implements PhoneFragemnt.CallBack {
    private NoScrollViewPager noScrollViewPager;
    private NoViewPagerAdapter adapter;

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_forget_password;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        noScrollViewPager = findViewById(R.id.noViewPager);

        noScrollViewPager.setScanScroll(false);
        adapter = new NoViewPagerAdapter(getSupportFragmentManager());
        noScrollViewPager.setAdapter(adapter);

    }

    @Override
    public void setCallBack(String value) {
        noScrollViewPager.setCurrentItem(1);
        Arad.bus.post(new EventModel<String>(19040300,value));

    }


    class NoViewPagerAdapter extends FragmentPagerAdapter {

        public NoViewPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return PhoneFragemnt.newInstance();
            } else
                return VersionPasswordFragment.newInstance();
        }

        @Override
        public int getCount() {
            return 2;
        }
    }

}
